#pragma once

#include <memory>
#include <vector>

#include <btBulletDynamicsCommon.h>
#include <physics_ISystem.h>
#include <physics_DebugVertex.h>

class I3D_System;
class BulletGround;
class IPhysicsRigid;
class IPhysicsJoint;
class BulletTestBall;
class BulletDebugDraw;

class BulletSystem : public IPhysicsSystem {
public:
	BulletSystem();
	~BulletSystem();
	IPhysicsRigid* CreateRigid(RigidBodyParam &param) override;
	IPhysicsJoint* CreateJoint(JointParam &param, IPhysicsRigid &rigid_1, IPhysicsRigid &rigid_2) override;
	void StepSimulation() override;
	void CreateDebugDraw(std::vector<PhysicsDebugVertex> &rVertex) override;
	void DrawDebug() override;

private:
	std::unique_ptr<btDefaultCollisionConfiguration> m_upCollisionConfigtation;
	std::unique_ptr<btCollisionDispatcher> m_upDispatcher;
	std::unique_ptr<btBroadphaseInterface> m_upPairCache;
	std::unique_ptr<btSequentialImpulseConstraintSolver> m_upSolver;
	std::unique_ptr<btDiscreteDynamicsWorld> m_upWorld;

	std::unique_ptr<BulletGround> m_upGround;
	std::unique_ptr<BulletDebugDraw> m_upDebug;
};
